<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>员工账号列表</title>
    <link href="/favicon.ico"   rel="shortcut"  />
    <link href="/Public/wxCMS/css/bootstrap.min.css" rel="stylesheet">
    <link href="/Public/wxCMS/css/bootstrap-table.css" rel="stylesheet">
    <link href="/Public/wxCMS/css/ssi-uploader.min.css" rel="stylesheet">
    <link href="/Public/wxCMS/css/styles.css" rel="stylesheet">
    <link href="/Public/wxCMS/css/home.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <script src="/Public/wxCMS/js/html5shiv.js"></script>
    <script src="/Public/wxCMS/js/respond.min.js"></script>
    <![endif]-->

</head>

<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#sidebar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#"><span>实+网</span>后台管理系统</a>
            <ul class="user-menu">
                <li class="dropdown pull-right">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-user"></span> <?php echo ($_SESSION['user']['name']); ?>  <span class="caret"></span></a>
                    <ul class="dropdown-menu" role="menu">
                        <li id="user-info" data-index="<?php echo ($_SESSION['user']['id']); ?>"><a href="javascript:;"><span class="glyphicon glyphicon-user"></span> 重置密码</a></li>
                        <li id="user-logout" data-index="<?php echo ($_SESSION['user']['id']); ?>"><a href="javascript:;"><span class="glyphicon glyphicon-log-out"></span> 退出</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div><!-- /.container-fluid -->
</nav>

<div id="sidebar-collapse" class="col-sm-3 col-lg-2 sidebar">
    <form role="search">
        <div class="form-group">

        </div>
    </form>
    <ul class="nav menu">
        <li><a href="<?php echo U('/Home/Index/index');?>"><span class="glyphicon glyphicon-dashboard"></span> 首页</a></li>
        <li class=""><a href="<?php echo U('/Home/Slider/index');?>"><span class="glyphicon glyphicon-th"></span> 轮播图管理</a></li>
        <li class="parent ">
            <a href="#">
                <span class="glyphicon glyphicon-list"></span> 成品展示管理 <span data-toggle="collapse" href="#sub-item-1" class="icon pull-right"><em class="glyphicon glyphicon-s glyphicon-plus"></em></span>
            </a>
            <ul class="children collapse" id="sub-item-1">
                <li>
                    <a class="" href="<?php echo U('/Home/Show/aderShow');?>?id=1">
                        <span class="glyphicon glyphicon-share-alt"></span> 休闲照
                    </a>
                </li>
                <li>
                    <a class="" href="<?php echo U('/Home/Show/aderShow');?>?id=2">
                        <span class="glyphicon glyphicon-share-alt"></span> 儿童照
                    </a>
                </li>
                <li>
                    <a class="" href="<?php echo U('/Home/Show/aderShow');?>?id=3">
                        <span class="glyphicon glyphicon-share-alt"></span> 婚纱照
                    </a>
                </li>
            </ul>
        </li>
        <li><a href="<?php echo U('/Home/Product/index');?>"><span class="glyphicon glyphicon-list"></span> 背景列表</a></li>
        <li><a href="<?php echo U('/Home/Decorate/index');?>"><span class="glyphicon glyphicon-list"></span> 装饰列表</a></li>
      <!--  <li class=""><a href="<?php echo U('/Home/Client/index');?>"><span class="glyphicon glyphicon-list"></span> 客户列表</a></li>-->
        <li><a href="<?php echo U('/Home/PhotoBox/index');?>"><span class="glyphicon glyphicon-list"></span> 相框相册管理</a></li>
        <li><a href="<?php echo U('/Home/Orders/index');?>"><span class="glyphicon glyphicon-list"></span> 订单列表</a></li>
        <li role="presentation" class="divider"></li>
        <li class="parent active">
            <a href="#">
                <span class="glyphicon glyphicon-list"></span> 系统管理 <span data-toggle="collapse" href="#sub-item-2" class="icon pull-right"><em class="glyphicon glyphicon-s glyphicon-plus"></em></span>
            </a>
            <ul class="children collapse in" id="sub-item-2">
                <li>
                    <a class="" href="<?php echo U('/Home/Staff/index');?>">
                        <span class="glyphicon glyphicon-share-alt"></span> 员工账号管理
                    </a>
                    <a class="" href="<?php echo U('/Home/CheckAuth/index');?>">
                        <span class="glyphicon glyphicon-share-alt"></span> 用户组管理
                    </a>
                    <a class="" href="<?php echo U('/Home/CheckAuth/auth_list');?>">
                        <span class="glyphicon glyphicon-share-alt"></span> 权限列表
                    </a>
                </li>
               <!-- <li>
                    <a class="" href="javascript:;" id="pay-setting">
                        <span class="glyphicon glyphicon-share-alt"></span> 支付方式管理
                    </a>
                </li>-->
            </ul>
        </li>
    </ul>
</div><!--/.sidebar-->
<div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">
    <div class="row">
        <ol class="breadcrumb">
            <li><a href="<?php echo U('/Home/Index/index');?>"><span class="glyphicon glyphicon-home"></span></a></li>
            <li class="active">首页</li>
        </ol>
    </div><!--/.row-->


    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">员工账号列表
                         <button type="button" class="btn btn-primary add-banner" data-toggle="modal" data-target="#myModal">新增员工</button>
                </div>
                <div class="panel-body">
                    <table id="tb_departments"></table>
                </div>
            </div>
        </div>
    </div><!--/.row-->



</div>	<!--/.main-->


<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                   新增用户
                </h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" role="form">
                    <fieldset>
                        <legend>账号信息</legend>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="name">用户名</label>
                            <div class="col-sm-4">
                                <input class="form-control" id="name" type="text" placeholder="请输入账号信息"/>
                            </div>
                            <label class="col-sm-2 control-label" for="password">密码</label>
                            <div class="col-sm-4">
                                <input class="form-control" id="password" type="password" placeholder="请输入密码"/>
                            </div>
                        </div>
                    </fieldset>
                    <fieldset>
                        <legend>请选择用户组</legend>
                        <div class="form-group">
                            <label for="disabledSelect"  class="col-sm-2 control-label">用户组</label>
                            <div class="col-sm-10">
                                <select id="disabledSelect" class="form-control">
                                    <option value="">请选择用户组</option>
                                    <?php if(is_array($roue)): $i = 0; $__LIST__ = $roue;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vo['id']); ?>"><?php echo ($vo['title']); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                                </select>
                            </div>
                        </div>
                    </fieldset>


                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
                <button type="button" class="btn btn-primary" id="add-user">
                    新增
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

<script src="/Public/wxCMS/js/jquery-1.11.1.min.js"></script>
<script src="/Public/wxCMS/js/bootstrap.min.js"></script>
<script src="/Public/wxCMS/js/bootstrap-table.js"></script>
<script src="/Public/wxCMS/js/ssi-uploader.js" type="text/javascript"></script>
<script src="/Public/wxCMS/js/layer.js" type="text/javascript"></script>
<script src="/Public/wxCMS/js/user-action.js"></script>
<script>
    $(function () {
        //1.初始化Table
        var oTable = new TableInit();
        oTable.Init();
    });
    var TableInit = function () {
        var oTableInit = new Object();
        //初始化Table
        oTableInit.Init = function () {
            $('#tb_departments').bootstrapTable({
                url: '<?php echo U("get_user_list");?>',         //请求后台的URL（*）
                toolbar: '#toolbar', //工具按钮用哪个容器
                striped: true, //是否显示行间隔色
                cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                pagination: true, //是否显示分页（*）
                sortable: false, //是否启用排序
                sortOrder: "asc", //排序方式
                queryParams: oTableInit.queryParams,//传递参数（*）
                sidePagination: "server", //分页方式：client客户端分页，server服务端分页（*）
                pageNumber:1, //初始化加载第一页，默认第一页
                pageSize: 10, //每页的记录行数（*）
                pageList: [10, 25, 50], //可供选择的每页的行数（*）
                search: false, //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                strictSearch: true,
                showColumns: true, //是否显示所有的列
                showRefresh: true, //是否显示刷新按钮
                minimumCountColumns: 2, //最少允许的列数
                clickToSelect: false, //是否启用点击选中行
                uniqueId: "timestamp", //每一行的唯一标识，一般为主键列
                showToggle:false, //是否显示详细视图和列表视图的切换按钮
                cardView: false, //是否显示详细视图
                detailView: false, //是否显示父子表
                locale: "zh-CN",//中文支持,
                columns: [
                    {
                        field: 'name',
                        title: '用户名',
                    },  {
                        field: 'group_title',
                        title: '管理组',
                    }, {
                        field: 'ac_time',
                        title: '创建时间'
                    }, {
                        field: 'id',
                        title: '操作',
                        formatter:function(value,row){
                            return '<button class="btn btn-warning " onclick="deit_user('+value+')">修改密码</button>'+
                                    '&nbsp;<button class="btn btn-danger "  onclick="del_user('+value+')">删除</button>' ;
                        }
                    }
                ],
                onExpandRow: function (index, row, $detail) {
                    oTableInit.InitSubTable(index, row, $detail);
                },

            });
        };

        //得到查询的参数
        oTableInit.queryParams = function (params) {
            var temp = { //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                limit: params.limit, //页面大小
                offset: params.offset, //页码
                departmentname: $("#txt_search_departmentname").val(),
                statu: $("#txt_search_statu").val(),
            };
            return temp;
        };
        return oTableInit;
    };

    //新增员工
    $('#add-user').click(function(){
        var name=$('#name').val();
        var password=$('#password').val();
        var disabledSelect=$('#disabledSelect').val();
        if(name==''||password==''||disabledSelect==''){
            layer.msg('还有未填写项,请检查！！');return;
        }
        $.post('<?php echo U("add_user");?>',{name:name,password:password,group_id:disabledSelect},function(resutl){
            if(!resutl.success){
                layer.msg(resutl.message);return;
            }
            layer.msg('新增用户成功', {icon: 1});
            $("#myModal").modal('hide');
            $('#tb_departments').bootstrapTable(
                    "refresh",
                    {
                        url:"<?php echo U('get_user_list');?>"
                    }
            );
        })
    });

    function deit_user(id){
        layer.prompt({title: '请输入密码，并确认', formType: 1}, function(pass, index){
            layer.close(index);
            layer.prompt({title: '请再次输入密码，并确认', formType: 1}, function(text, index){
                layer.close(index);
                if(pass!=text){
                    layer.msg('两次输入密码不一致');
                }
                $.post('<?php echo U("edit_pass");?>',{id:id,pass:pass},function(resutl){
                    layer.msg(resutl.message);
                });
            });
        });
    }

    //删除该组照片
    function  del_user(id){
        layer.confirm('您确定要删除该账号吗?', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.get('<?php echo U("del_user");?>?id='+id,function(result){
                if(result.success){
                    layer.msg(result.message, {icon: 1});
                    $('#tb_departments').bootstrapTable(
                            "refresh",
                            {
                                url:"<?php echo U('get_user_list');?>"
                            }
                    );
                }else{
                    layer.msg(result.message, {icon: 2});
                }
            });
        });
    }


</script>
</body>

</html>